<template>
    <a-card :bordered="false">
        <!-- 查询区域 -->
        <div class="table-page-search-wrapper">
            <a-form layout="inline" @keyup.enter.native="searchQuery">
                <a-row :gutter="24">
                    <a-col :span="6" :sm="6">
                        <a-form-item label="初审分组">
                            <a-select v-model="cxj_jscs_fz_id" placeholder="请选择初审分组" @change="handleSelectFz">
                                <a-select-option v-for="item in xszjfzData" :key="item.id" :value="item.cxj_jscs_fz_id">
                                    {{item.jscs_fz_mc}}
                                </a-select-option>
                            </a-select>
                        </a-form-item>
                    </a-col>
                    <a-col :span="12" :sm="12">
                        <div class="tjdata">
                            <span>总数量：<span class="count">{{reviewStatistics.sum}}</span></span>
                            <span>已评分：<span class="count">{{reviewStatistics.ypf}}</span></span>
                            <!-- <span>暂存：</span> -->
                            <span>未评分：<span class="count">{{reviewStatistics.wpf}}</span></span>
                            <span>评分状态: <span class="count">{{reviewStatistics.pfzt==0?'未提交':reviewStatistics.pfzt==1?'已提交': ''}}</span></span>
                        </div>
                    </a-col>
                    <a-col :span="6" :sm="6">
                        <a-button type="primary" style="margin: 0px;" :disabled="reviewStatistics.pfzt==0?false:reviewStatistics.pfzt==1?true:''" @click="submitQrode(reviewStatistics)">签名并提交</a-button>
                        <a-button type="primary" style="margin: 0px 0 0 10px;" :disabled="reviewStatistics.pfzt==0" @click="ratingPreview(1)">评分预览</a-button>
                    </a-col>
                </a-row>
            </a-form>
          <p style="color: #ff0000;font-size: 16px;">该组成果全部评审完成后，点击"全部提交"完成评分，提交后不可修改。</p>
        </div>
        <!-- 查询区域-END -->
        <!-- 操作按钮区域 高级查询区域-->
        <div class="table-operator" style="display: flex; align-items: center;justify-content: space-between;"></div>
        <!-- table区域-begin -->
        <div>
            <!-- <h2 style="text-align:center;font-size: 20px;">{{new Date().getFullYear()}}年度电力科技创新奖技术初审表</h2> -->
            <h2 style="text-align:center;font-size: 20px;">
                {{new Date().getFullYear()}}年度电力创新奖技术初审表
                <a-button type="primary" style="margin: 0px;" @click="downloadFile">初审表下载</a-button>
            </h2>
            <!-- tableLayout="auto" -->
            <a-table
                ref="table"
                size="middle"
                :scroll="{x: 1100}"
                bordered
                rowKey="cxj_xmbh"
                :columns="columns"
                :dataSource="dataSource"
                :pagination="ipagination"
                :loading="loading"
                class="j-table-force-nowrap"
                @change="handleTableChange">
                <template
                v-for="col in ['jscs_cxx', 'jscs_xjx', 'jscs_ssxg', 'jscs_jjxy', 'jscs_tgjz']"
                :slot="col"
                slot-scope="text, record, index"
            >
                    <div :key="col">
                        <a-popover placement="top" v-if="record.editable">
                            <template slot="content">
                                <div v-if="col=='jscs_cxx'">
                                    <p>有较大技术创新，国内、行业首创，21-25分</p>
                                    <p>有一定技术创新，属技术重大改进，10-20分</p>
                                    <p>有一定技术改良，创新性一般，1-9分</p>
                                </div>
                                <div v-else-if="col=='jscs_xjx'">
                                    <p>国际先进、国内领先，技术难度大，21-25分</p>
                                    <p>国内先进、行业领先，较大技术难度，10-20分</p>
                                    <p>接近国内及行业领先，有一定技术难度，1-9分</p>
                                </div>
                                <div v-else-if="col=='jscs_ssxg'">
                                    <p>成果实施后管理及技术问题得到根本解决，16-20分</p>
                                    <p>成果实施后，管理及技术问题得到基本解决，10-15分</p>
                                    <p>成果实施后，管理及技术问题得到部分解决，1-9分</p>
                                </div>
                                <div v-else-if="col=='jscs_jjxy'">
                                    <p>社会和经济效益显著（500万以上），16-20分</p>
                                    <p>社会和经济效益较大（300万以上），10-15分</p>
                                    <p>有一定社会和经济效益（100万以上），1-9分</p>
                                </div>
                                <div v-else-if="col=='jscs_tgjz'">
                                    <p>具备极强推广价值，行业适用性强，8-10分</p>
                                    <p>具备较强推广价值，行业适用性一般，6-8分</p>
                                    <p>具备一定推广价值，1-5分</p>
                                </div>
                            </template>
                            <a-input
                                type="number"
                                style="margin: -5px 0"
                                :value="text"
                                @change="e => handleChange(e.target.value, record.key, col)"
                            />
                        </a-popover>
                        <template v-else>
                            {{ text }}
                        </template>
                    </div>
                </template>
                <template slot="jscs_pingjiayj" slot-scope="text, record, index">
                    <div key="jscs_pingjiayj">
                        <a-textarea
                        :value="text"
                        v-if="record.editable"
                        placeholder="请填写评审意见"
                        @change="e => handleChange(e.target.value, record.key, 'jscs_pingjiayj')"
                        @click="e => handleOpinion(e.target.value, record.key, record.cxj_cxj_id, 'jscs_pingjiayj')"
                        :auto-size="{ minRows: 1, maxRows: 5 }"
                        />
                        <template v-else>
                            <a-popover title="" placement="bottom" arrow-point-at-center>
                                <template slot="content">
                                    <p style="max-width:300px; word-break: break-all;">{{ text }}</p>
                                </template>
                                <span class="sl-span">{{ text }}</span>
                            </a-popover>
                        </template>
                    </div>
                </template>
                <template slot="jscs_sfhb" slot-scope="text, record">
                    <div key="jscs_sfhb">
                        <a-radio-group default-value="N" v-model="record.jscs_sfhb">
                            <a-radio value="Y" :disabled="!record.editable">是</a-radio>
                            <a-radio value="N" :disabled="!record.editable">否</a-radio>
                        </a-radio-group>
                    </div>
                </template>
                <span slot="cgzlAction" slot-scope="text, record">
                    <a @click="handlePreview(record)">查看</a>
                </span>
                <span slot="jscs_zongfen" slot-scope="text, record">
                    <span>{{record.jscs_zongfen}}</span>
                </span>
                <template slot="action" slot-scope="text, record, index">
                    <div class="editable-row-operations">
                        <span v-if="!record.editable">
                            <a v-if="record.jscs_zt==1" disabled>评分</a>
                            <a v-else :disabled="editingKey !== ''?true:false" @click="() => edit(record.key)">评分</a>
                        </span>
                        <!-- <a-divider type="vertical" /> -->
                        <span v-else>
                            <a @click="() => save(record.key, record)">保存</a>
                            <a-popconfirm title="真的放弃编辑吗?" @confirm="() => cancel(record.key)">
                                <a>取消</a>
                            </a-popconfirm>
                        </span>
                    </div>
                </template>

            </a-table>
        </div>
        <cxj-jscs-pf-js-modal ref="modalForm" @ok="modalFormOk"></cxj-jscs-pf-js-modal>
        <!-- 二维码 -->
        <a-modal
            :visible="qrcodeVisible"
            @cancel="handleCancel()"
            title="请用手机扫二维码签名"
            centered
            :footer="null"
            width="400px"
            height="400px"
        >
            <vue-qr :text="imgQrUrl" :size="360" :margin="0"></vue-qr>
        </a-modal>
        <!-- pdf -->
        <view-pdf :params="pafParams" :showPdf="showpdf" @reset="getQrUrl" @sure="handleSure" :pafBtn="pafBtn"></view-pdf>
        <OpinionModal :showFlag="opinionFlag" :opinion="opinionValue" @updateOpinion="updateOpinion"/>
    </a-card>
</template>

<script>
import VueQr from 'vue-qr'
import viewPdf from '@/views/cxj/viewPdf'
import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import CxjJscsPfJsModal from './modules/CxjJscsPfJsModal'
import { getAction } from '../../api/manage'
import qs from 'qs';
import Vue from 'vue'
import { USER_INFO, ACCESS_TOKEN } from "@/store/mutation-types"
import {
  // 初审项目评分表-信息化类-查二维码签名状态
  cxjcXxhCheckQrcode,
  // 初审项目评分表-信息化类-查二维码
  cxjcXxhSubmitQrcode,
  // 初审项目评分表-信息化类-获取分组项目
  cxjcsGetFzxmListByFzidXxh,
  // 初审项目评分表-信息化类-评分保存或修改
  cxjcsSavePfXxh,
  // 初审项目评分表-信息化类-评分提交
  cxjcsSubmitPXxh,
  // 信息化初审评分表-评分统计-专家
  jscsPfTjZjXxh
} from  "@/api/api";

import {
    // 技术初审评分表-导出
    jscsPfExport
} from "@/api/manage"
import OpinionModal from './OpinionModal/index.vue'
export default {
    name: 'CxjJscsPfJsList',
    mixins:[mixinDevice],
    components: {
        OpinionModal,
        CxjJscsPfJsModal,
        VueQr,
        viewPdf
    },
    data () {
        // this.cacheData = dataSource.map(item => ({ ...item }));
        return {
            pdfFilePath: '',
            pafBtn: false,
            showpdf: false,
            pafParams: {},
            qrcodeVisible: false,
            imgQrUrl: '',
            xszjfzData: [],
            cxj_jscs_fz_id: '',
            reviewStatistics: '',
            cacheData: [],
            description: '初审项目评分表-技术类-获取分组项目',
            // 表头
            columns: [
                {
                title: '序号',
                dataIndex: '',
                key: 'rowIndex',
                width: '5%',
                customCell: () => {
                    return {
                    style: {
                        'min-width': '40px',
                    },
                    };
                },
                align:"center",
                // fixed: 'left',
                customRender:function (t,r,index) {
                    return parseInt(index)+1;
                }
                },
                {
                title: '成果编号',
                align: "center",
                dataIndex: 'cxj_xmbh',
                width: '10%',
                customCell: () => {
                    return {
                    style: {
                        'min-width': '80px',
                    },
                    };
                },
                },
                {
                title: '成果名称',
                dataIndex: 'cxj_mc_zw',
                width: '15%',
                customCell: () => {
                    return {
                    style: {
                        'min-width': '130px',
                    },
                    };
                },
                },
                {
                title: '成果资料',
                align: "center",
                dataIndex: 'cgzlAction',
                width: '5%',
                customCell: () => {
                    return {
                        style: {
                            'min-width': '80px',
                        },
                    };
                },
                scopedSlots: { customRender: 'cgzlAction' }
                },
                {
                title: '审查意见',
                // width: 800,
                align: 'center',
                children: [
                    {
                    title: '创新性',
                    align: "center",
                    width: '7%',
                    customCell: () => {
                        return {
                        style: {
                            'min-width': '100px',
                        },
                        };
                    },
                    children: [{
                        title: "25分",
                        align:"center",
                        width: '7%',
                        customCell: () => {
                        return {
                            style: {
                            'min-width': '100px',
                            },
                        };
                        },
                        dataIndex: "jscs_cxx",
                        scopedSlots: { customRender: 'jscs_cxx' }
                    }]
                    },
                    {
                    title: '技术先进性及技术难度',
                    align: "center",
                    width: '7%',
                    customCell: () => {
                        return {
                        style: {
                            'min-width': '100px',
                        },
                        };
                    },
                    children: [{
                        title: "25分",
                        align:"center",
                        width: '7%',
                        customCell: () => {
                        return {
                            style: {
                            'min-width': '100px',
                            },
                        };
                        },
                        dataIndex: "jscs_xjx",
                        scopedSlots: { customRender: 'jscs_xjx' }
                    }]
                    },
                    {
                    title: '成果实施效果',
                    align: "center",
                    width: '7%',
                    customCell: () => {
                        return {
                        style: {
                            'min-width': '100px',
                        },
                        };
                    },
                    children: [{
                        title: "20分",
                        align:"center",
                        width: '7%',
                        customCell: () => {
                        return {
                            style: {
                            'min-width': '100px',
                            },
                        };
                        },
                        dataIndex: "jscs_ssxg",
                        scopedSlots: { customRender: 'jscs_ssxg' }
                    }]
                    },
                    {
                    title: '成果社会及经济效益',
                    width: '7%',
                    customCell: () => {
                        return {
                        style: {
                            'min-width': '100px',
                        },
                        };
                    },
                    children: [{
                        title: "20分",
                        align:"center",
                        width: '7%',
                        customCell: () => {
                        return {
                            style: {
                            'min-width': '100px',
                            },
                        };
                        },
                        dataIndex: "jscs_jjxy",
                        scopedSlots: { customRender: 'jscs_jjxy' }
                    }]
                    },
                    {
                    title: '成果推广应用价值',
                    width: '7%',
                    customCell: () => {
                        return {
                        style: {
                            'min-width': '100px',
                        },
                        };
                    },
                    children: [{
                        title: "10分",
                        align:"center",
                        width: '7%',
                        customCell: () => {
                        return {
                            style: {
                            'min-width': '100px',
                            },
                        };
                        },
                        dataIndex: "jscs_tgjz",
                        scopedSlots: { customRender: 'jscs_tgjz' }
                    }]
                    },
                    {
                    title: '合计',
                    align: "center",
                    width: '8%',
                    customCell: () => {
                        return {
                        style: {
                            'min-width': '60px',
                        },
                        };
                    },
                    dataIndex: 'jscs_zongfen',
                    scopedSlots: { customRender: 'jscs_zongfen' },
                    sorter: (a, b) => b.total_score - a.total_score,
                    },
                    {
                        title: '评审意见',
                        dataIndex: 'jscs_pingjiayj',
                        scopedSlots: { customRender: 'jscs_pingjiayj' }
                    },
                    {
                        title: '是否回避',
                        dataIndex: 'jscs_sfhb',
                        scopedSlots: { customRender: 'jscs_sfhb' }
                    }
                ]
                },
                {
                title: '操作',
                dataIndex: 'action',
                align: "center",
                fixed: "right",
                width: 110,
                scopedSlots: { customRender: 'action' }
                }
            ],
            url: {
                list: "/cxj/cxjJscsPfJs/list",
                delete: "/cxj/cxjJscsPfJs/delete",
                deleteBatch: "/cxj/cxjJscsPfJs/deleteBatch",
                exportXlsUrl: "/cxj/cxjJscsPfJs/exportXls",
                importExcelUrl: "cxj/cxjJscsPfJs/importExcel",
                // 初审分组专家表-获取分组列表
                cxjCsGetZjFz: '/cxj/cxjJscsFzZj/cxjCsGetZjFz'
            },
            superFieldList:[],
            // 分组id
            fzid: "",
            editingKey: '',
            queryParam: {},
            dictOptions:{},
            //superFieldList:[],
            fileStatus: "",
            selectedRowKeys: [],
            selectionRows: [],
            loading: false,
            isorter: {
                column: 'createTime',
                order: 'desc',
            },
            dataSource: [],
            ipagination: {
                current: 1,
                pageSize: 10,
                pageSizeOptions: ['10', '20', '100'],
                showTotal: (total, range) => {
                return range[0] + "-" + range[1] + " 共" + total + "条"
                },
                showQuickJumper: true,
                showSizeChanger: true,
                total: 0
            },
            opinionFlag: false,
            opinionKey: '',
            opinionValue: '',
        }
    },
    created() {
        this.$set(this.dictOptions, 'isValid', [{text:'是',value:'Y'},{text:'否',value:'N'}])
        this.getSuperFieldList();
        this.fetchCxjCsGetZjFz();
     },
    watch: {
        dataSource(){
            this.updateDataSource();
        }
    },
    methods: {
        handleOpinion(value, key, id, column) {
            this.opinionKey = id
            this.opinionValue = value
            this.opinionFlag = !this.opinionFlag
        },
        updateOpinion(value) {
            this.opinionFlag = !this.opinionFlag
            this.dataSource.forEach(item => {
                if(item.cxj_cxj_id == this.opinionKey) {
                    item.jscs_pingjiayj = value
                }
            })
        },
        handleSure() {
            let user = Vue.ls.get(USER_INFO);
            let formData = new FormData();
            formData.append('fzid', this.fzid)
            formData.append('zjid', user.id)
            const that = this
            cxjcsSubmitPXxh(formData).then(res=>{
                if (res.code == 200) {
                    // 签名成功后获取评分状态，保证未提交变成已提交
                    this.getjscsPfTjZj()
                    that.$message.success(res.message);
                    that.fetchCxjCsGetZjFz();
                } else {
                    that.$message.warning(res.message);
                    that.fetchCxjCsGetZjFz();
                }
            })
        },
        handleCancel() {
            clearInterval(this.qrTimer)
            this.qrcodeVisible = false;
        },
         // 评分预览
        ratingPreview(flag) {
            this.pafBtn = flag == 1 ? false : true
            let user = Vue.ls.get(USER_INFO);
            this.pafParams = {
                fzid: this.fzid,
                zjid: user.id
            }
            this.showpdf = !this.showpdf
        },
        // 查询签名状态
        checkSignStatus(params) {
            clearInterval(this.qrTimer)
            this.qrTimer = setInterval(() => {
                cxjcXxhCheckQrcode(params).then(res=>{
                    if (res.result) {
                        clearInterval(this.qrTimer)
                        this.qrcodeVisible = false
                        setTimeout(() => {
                            this.ratingPreview(2)
                        }, 4000)
                        this.$message.success("签名成功！")
                    }
                }).catch(err => {
                    this.$message.error("查询签名状态失败！")
                })
            }, 2000)
        },
        submitQrode(record) {
            if(record.ypf == record.sum){
                this.getQrUrl()
            } else {
                this.$message.warning("还未完成评分，无法提交！")
            }
        },
        // 查询二维码地址
        getQrUrl() {
            let user = Vue.ls.get(USER_INFO);
            let that = this
            let formData = new FormData();
            formData.append('fzid', this.fzid)
            formData.append('zjid', user.id)
            cxjcXxhSubmitQrcode(formData).then(res=>{
                if (res.code === 200) {
                    this.imgQrUrl = `${window.location.origin}${res.result}&path=cxjJscsPfXxh`
                    this.qrcodeVisible = true
                    this.checkSignStatus({
                        fzid: that.fzid,
                        zjid: user.id
                    })
                } else {
                    this.$message.error(res.message)
                }
            }).catch(err => {
                this.$message.error("查询二维码失败！")
            })
        },
        // 初审表下载
        downloadFile(){
            console.log('初审表下载')
            let data = {
                fzid: this.cxj_jscs_fz_id
            }
            jscsPfExport(data).then(res=>{
                this.downfn('初审表下载',res);
            })
        },
        downfn(name, res) {
            const _res = res;
            let blob = new Blob([_res], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'});
            let downloadElement = document.createElement("a");
            let href = window.URL.createObjectURL(blob); //创建下载的链接
            downloadElement.href = href;
            downloadElement.download = name; //下载后文件名
            document.body.appendChild(downloadElement);
            downloadElement.click(); //点击下载
            document.body.removeChild(downloadElement); //下载完成移除元素
            window.URL.revokeObjectURL(href); //释放掉blob对象
        },
        updateDataSource(){
            // console.log('数据====',this.dataSource)
            this.dataSource.map(item=>{
                item.jscs_zongfen = Number(item.jscs_cxx)+Number(item.jscs_ssxg)+Number(item.jscs_jjxy)+Number(item.jscs_tgjz)+Number(item.jscs_xjx)
            })
        },
        // 切换分组
        handleSelectFz(value){
            this.fzid = value;
            this.getjscsPfTjZj();
            this.loadData(1);
        },
        // 获取技术初审评分表-评分统计
        getjscsPfTjZj(){
            let formData = new FormData();
            formData.append('fzid', this.fzid)
            jscsPfTjZjXxh(formData).then(res=>{
                // console.log('评分统计',res)
                if(res.code == 200) {
                    this.reviewStatistics = res.result;
                } else {
                    this.$message.warning(res.message)
                }
            })
        },
        // 全部提交
        submitAll(record){
        console.log(record)
        let that = this;
        console.log('FENZU',this.fzid)
        if(record.ypf == record.sum){
            let user = Vue.ls.get(USER_INFO);
            let formData = new FormData();
            formData.append('fzid', this.fzid)
            formData.append('zjid', user.id)
            this.$confirm({
            title: '确定要全部提交吗?',
            okText: '确定',
            cancelText: '取消',
            onOk() {
                cxjcsSubmitPXxh(formData).then(res=>{
                console.log('--------',res)
                if (res.code == 200) {
                    that.$message.success(res.message);
                    that.fetchCxjCsGetZjFz();
                } else {
                    that.$message.warning(res.message);
                    that.fetchCxjCsGetZjFz();
                }
                })
            },
            onCancel() {
                console.log('Cancel');
            },
            });
        } else {
            this.$message.warning("还未完成评分，无法提交！")
        }
        },
        resetSearchForm () {
        this.fetchCxjCsGetZjFz();
        },
        // 获取分组列表【用于信息化类-获取分组项目列表参数fzid】
        fetchCxjCsGetZjFz(){
            let user = Vue.ls.get(USER_INFO);
            getAction(this.url.cxjCsGetZjFz, {sysZjId: user.id, flbh: 41}).then(res=>{
                if(res.success) {
                    if (res.result.length) {
                        // console.log('分组', res.result)
                        this.xszjfzData = res.result;
                        this.fzid = res.result[0].cxj_jscs_fz_id;
                        this.cxj_jscs_fz_id = res.result[0].cxj_jscs_fz_id;
                    }
                    this.loadData();
                    this.getjscsPfTjZj();
                }
            })
        },
        // 查看
        handlePreview(record){
        console.log('查看', record.cxj_cxj_id)
        let token = Vue.ls.get(ACCESS_TOKEN);
        sessionStorage.setItem('token', token);
        let routeData = this.$router.resolve({
            path: '/shenbao/declare',
            query: {
                type: record.fl_id,
                cxj_cxj_id: record.cxj_cxj_id,
                isHead: 2,
                from: 'zj',
                xmztbh: record.xmztbh,
                cxj_xmbh: record.cxj_xmbh,
                cxj_mc_zw: record.cxj_mc_zw
            }
        });
        window.open(routeData.href, '_blank');
        },

        /* 对行内进行修改开始 */
        handleChange(value, key, column) {
        const newData = [...this.dataSource];
        const target = newData.filter(item => key === item.key)[0];
        // console.log('target',target)
        if (column == 'jscs_cxx' && value > 25) {
            value = 25;
        } else if (column == 'jscs_xjx' && value > 25) {
            value = 25;
        } else if (column == 'jscs_ssxg' && value > 20) {
            value = 20;
        } else if (column == 'jscs_jjxy' && value > 20) {
            value = 20;
        } else if (column == 'jscs_tgjz' && value > 10) {
            value = 10;
        }
          if (value < 1) {
            value = 1;
          }
        if (target) {
            target[column] = value;
            // console.log('target[column]',target[column])
            this.dataSource = newData;
            console.log('input',this.dataSource)
        }
        },
        edit(key) {
        const newData = [...this.dataSource];
        const target = newData.filter(item => key === item.key)[0];
        this.editingKey = key;
        if (target) {
            target.editable = true;
            this.dataSource = newData;
        }
        },
        save(key, record) {
            console.log('====',record.cxj_cxj_id)
            const newData = [...this.dataSource];
            const newCacheData = [...this.cacheData];
            const target = newData.filter(item => key === item.key)[0];
            const targetCache = newCacheData.filter(item => key === item.key)[0];
            if (target && targetCache) {
                delete target.editable;
                this.dataSource = newData;
                Object.assign(targetCache, target);
                this.cacheData = newCacheData;
            }
            this.editingKey = '';
            let formData = {
                jscsCxx: record.jscs_cxx,
                jscsJjxy: record.jscs_jjxy,
                jscsPingjiayj: record.jscs_pingjiayj,
                // 是否回避
                jscsSfhb: record.jscs_sfhb,
                jscsSsxg: record.jscs_ssxg,
                jscsTgjz: record.jscs_tgjz,
                jscsXjx: record.jscs_xjx,
                cxjCxjId: record.cxj_cxj_id,
                id: record.id,
                jscsZt: record.jscs_zt
            }
            console.log('第二页数据',formData.cxjCxjId)
            cxjcsSavePfXxh(formData).then(res=>{
                if (res.code == 200) {
                    this.$message.success(res.message);
                    this.loadData();
                    this.getjscsPfTjZj();
                } else {
                    this.$message.warning(res.message);
                    this.loadData();
                    this.getjscsPfTjZj();
                }
            })

        },
        cancel(key) {
            const newData = [...this.dataSource];
            const target = newData.filter(item => key === item.key)[0];
            this.editingKey = '';
            if (target) {
                Object.assign(target, this.cacheData.filter(item => key === item.key)[0]);
                delete target.editable;
                this.dataSource = newData;
            }
        },
        /* 对行内进行修改结束 */

        /* 获取列表固定格式开始 */
        getQueryField() {
        //TODO 字段权限控制
        var str = "id,";
        this.columns.forEach(function (value) {
            str += "," + value.dataIndex;
        });
        return str;
        },
        // 获取分组项目
        loadData(arg) {
            if (arg === 1) {
                this.ipagination.current = 1;
            }
            this.loading = true;
            let user = Vue.ls.get(USER_INFO);
            let params = Object.assign(this.queryParam, this.isorter, this.filters)
            params.field = this.getQueryField();
            params.pageNo = this.ipagination.current;
            params.pageSize = this.ipagination.pageSize;
            params.fzid = this.fzid;
            params.zjid = this.zjid;
            cxjcsGetFzxmListByFzidXxh(qs.stringify(params)).then(res=>{
                if (res.success) {
                    this.dataSource = res.result.records || res.result;
                    this.dataSource.map((item,index)=>{
                        item.key = index;
                        item.total_score = item.jscs_zongfen;
                        if (!item.jscs_sfhb){
                            item.jscs_sfhb = "N";
                        }
                    })
                    this.cacheData = this.dataSource;
                    if (res.result.total) {
                        this.ipagination.total = res.result.total;
                    } else {
                        this.ipagination.total = 0;
                    }
                }
                if (res.code === 510) {
                    this.$message.warning(res.message)
                }
                this.loading = false;
            })
        },
        onSelectChange(selectedRowKeys, selectionRows) {
            this.selectedRowKeys = selectedRowKeys;
            this.selectionRows = selectionRows;
        },
        onClearSelected() {
            this.selectedRowKeys = [];
            this.selectionRows = [];
        },
        modalFormOk() {
            // 新增/修改 成功时，重载列表
            this.loadData();
            //清空列表选中
            this.onClearSelected()
        },
        handleTableChange(pagination, filters, sorter) {
            //分页、排序、筛选变化时触发
            //TODO 筛选
            if (Object.keys(sorter).length > 0) {
                if (this.editingKey) {
                } else {
                    this.loadData();
                }
                this.isorter.column = sorter.field;
                this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
            } else {
                this.loadData();
            }
            this.ipagination = pagination;
            // this.loadData();
        },
        /* 获取列表固定格式结束 */





        initDictConfig(){},
        getSuperFieldList(){
            let fieldList=[];
            fieldList.push({type:'string',value:'sysZjId',text:'专家ID',dictCode:''})
            fieldList.push({type:'string',value:'cxjCxjId',text:'成果ID',dictCode:''})
            fieldList.push({type:'double',value:'jscsCxx',text:'技术创新性',dictCode:''})
            fieldList.push({type:'double',value:'jscsXjx',text:'技术先进性',dictCode:''})
            fieldList.push({type:'double',value:'jscsSsxg',text:'实用化程度',dictCode:''})
            fieldList.push({type:'double',value:'jscsJjxy',text:'经济效益',dictCode:''})
            fieldList.push({type:'double',value:'jscsTgjz',text:'推动作用',dictCode:''})
            fieldList.push({type:'string',value:'jscsPingjiayj',text:'评审意见',dictCode:''})
            fieldList.push({type:'double',value:'jscsZongfen',text:'总分',dictCode:''})
            fieldList.push({type:'string',value:'jscsZt',text:'评分状态',dictCode:''})
            fieldList.push({type:'string',value:'shijian',text:'年度',dictCode:''})
            fieldList.push({type:'string',value:'bz1',text:'备注1',dictCode:''})
            fieldList.push({type:'string',value:'bz2',text:'备注2',dictCode:''})
            fieldList.push({type:'string',value:'bz3',text:'备注3',dictCode:''})
            fieldList.push({type:'switch',value:'isValid',text:'是否有效'})
            this.superFieldList = fieldList
        }
    }
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
/deep/* {
  font-size: 14px;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
}
/deep/.ant-table-tbody > tr > td {
  word-break: break-all;
  white-space: normal;
  word-wrap:break-word;
  font-size:14px;
  padding:6px 3px!important;
}
/deep/.ant-table-tbody > tr > td > div {
  font-size: 14px;
}

/deep/.ant-table-thead > tr > th {
  word-break: break-all;
  white-space: normal;
  word-wrap:break-word;
  text-align: center;
  font-size:14px;
  padding:5px 3px!important;
}
.editable-row-operations a {
  margin-right: 8px;
}
.tjdata {
  // margin-top: 20px;
  span {
    margin-right:20px;
    line-height: 30px;
    font-size: 16px;
  }
}
.count {
  color: #ee9900;
  font-weight: 700;
  font-size: 16px;
}
/deep/.ant-table-tbody > tr > td:nth-child(10) {
  color: #ee9900!important;
  font-weight: 700;
  font-size: 16px;
}
.editable-row-operations a {
  margin: 0px 2px;
}
.table-page-search-wrapper .anty-form-btn .ant-form-item {
  margin-bottom: 10px;
}
// 用于解决表格气泡框字数过多时，不居中显示的问题
.sl-span{
    width: auto;
    max-width: 100%;
    display: inline-block; //会根据内容适配宽度
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    vertical-align: top; //添加此属性不会引起错位
}
</style>
